package com.mselivanov.vf5android;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

public class CharacterSelectActivity extends ListActivity {
	
	public static final String MOVES_TYPE_KEY = "moves-type";
	private int movesType = Characters.TYPE_DEFAULT;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		if (getIntent() != null) {
			Bundle bundle = getIntent().getExtras();
			if (bundle != null) {
				movesType = bundle.getInt(MOVES_TYPE_KEY);
			}
		}
		
		setContentView(R.layout.choose_type);
		setListAdapter(new CharactersAdapter(this));
	}
	
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
    	// start activity with character select
    	Intent intent = new Intent(this, MovesActivity.class);
    	
    	// put extra params into bundle and attach to intent
    	Bundle bundle = new Bundle();
    	bundle.putInt(MOVES_TYPE_KEY, movesType);
    	bundle.putInt(MovesActivity.CHARACTER_KEY, position);
    	intent.putExtras(bundle);
    	
    	startActivity(intent);
    }

}
